<template>
    <el-table :data="list" border>
        <el-table-column label="Id" prop="id"></el-table-column>
        <el-table-column label="房主Id" prop="landlord_id"></el-table-column>
        <el-table-column label="租户Id" prop="user_id"></el-table-column>
        <el-table-column label="类型" prop="type"></el-table-column>
        <el-table-column label="人数" prop="person_num"></el-table-column>
        <el-table-column label="地址"  prop="location"></el-table-column>
        <el-table-column label="价格" prop="price"></el-table-column>
        <el-table-column label="出租状态" prop="is_hire"></el-table-column>
        <el-table-column label="操作" width="250" >
            <template slot-scope="scope">
                <el-button type="danger" @click="deleteHouse(scope.$index,scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
import {deleteHouse, fetchAllHouses} from "../../api/houseManage";

export default {
    name: "houseManagement",
    data(){
        return{
            list:[],
        }
    },
    methods:{
        getAllHouses(){
            fetchAllHouses().then(res =>{
                this.list=res.data.list;
                console.log(this.list)
            })
        },
        deleteHouse(index,row){

            this.$confirm('是否要删除?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'}).then(() =>{
                console.log(row.id)
        })
        },
    },
    created() {
        this.getAllHouses();
    }
}
</script>

<style scoped>

</style>